package com.max.project.graphics.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import com.max.common.oauth.oauth10.OAuthParameter;
import com.max.common.oauth.oauth10.OAuthToken;
import com.max.common.oauth.oauth10.impl.OAuthApiTencentMicroBlog;
import com.max.common.util.JsonUtil;
import com.max.common.util.HttpTool.Response;
import com.max.project.graphics.service.MicroBlogTencentService;

/**
 * 
 * 项目名称:max-project-graphics
 * 文件名称:MicroBlogTencentServiceImpl.java
 * 文件描述:
 * 创建人员:chenyibo
 * 创建时间:2013-1-29 下午03:13:52
 * 修改人员:chenyibo
 * 修改时间:2013-1-29 下午03:13:52
 * 修改备注:
 * @version V1.0
 */
public class MicroBlogTencentServiceImpl implements MicroBlogTencentService
{
	
	
	private final static String api_host_tencent = "http://open.t.qq.com/api/";
	
	@Override
	public JSONObject statuses_user_timeline(
			String name, int size, long lastid, long pagetime, int feature) throws Exception 
	{
		JSONObject json = null;
		
		final String url = api_host_tencent + "statuses/user_timeline";
		List<OAuthParameter> paramList = new ArrayList<OAuthParameter>();
		paramList.add(new OAuthParameter("format","json"));
		paramList.add(new OAuthParameter("pageflag",lastid==0?"0":"1"));
		paramList.add(new OAuthParameter("pagetime",String.valueOf(pagetime)));
		paramList.add(new OAuthParameter("reqnum",String.valueOf(size)));
		paramList.add(new OAuthParameter("lastid",String.valueOf(lastid)));
		paramList.add(new OAuthParameter("name",name));
		paramList.add(new OAuthParameter("type","1"));
		paramList.add(new OAuthParameter("contenttype",String.valueOf(feature)));
		
		OAuthApiTencentMicroBlog api = new OAuthApiTencentMicroBlog();
		Response res = api.request("get", url, paramList, new OAuthToken("ff6a4688ade04a9bbd0a02d6c9411e49","d106815fea03c67195b1ad48516ec1e7"));
		json = res.asJSONObject();
		
		return json;
	}
	
	
	public static void main(String[] args) throws Exception
	{
		MicroBlogTencentServiceImpl microBlogTencentServiceImpl = new MicroBlogTencentServiceImpl();
//		System.out.println(microBlogTencentServiceImpl.statuses_user_timeline("meiyu0820", 50, 0, 1));
//		System.out.println(microBlogTencentServiceImpl.statuses_broadcast_timeline(20, 0, 1));
	}
}
